/*  -*- mode: c++; coding: utf-8; c-file-style: "stroustrup"; -*-

    Copyright 2008 Asier Aguirre <asier.aguirre@gmail.com>
    This file is part of Intromit.

    Intromit is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Intromit is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Intromit.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef PYMETADATA_IFACE_HH
#define PYMETADATA_IFACE_HH
//! \addtogroup python_backend
//@{

// INCLUDES
#include <Python.h>

// CLASS

//! Python interface for the module (uses Python-C API)
class pymetadata
{
    // PRIVATE FUNCTIONS
    static int load_metadata(char *file); // returns index to metadata in pymetadata_global or -1 if error

    // traverse metadata and generate pymetadata
    static int generate_class(int &position, int *metadata, char *doc, void *dl, PyObject *module);
    static int generate_postready(int &position, int *metadata, char *doc, void *dl, PyObject *module, int parent_is_class=0);
    static int generate_enum(int *metadata, char *doc, char *name, char *namespc, PyObject *module);

    // traverse metadata and convert C++ names to python names
    static int convert_names_to_python(int &position, int *metadata, char *doc);
    static void pythonize_class_name(char *name);
    static void pythonize_class_namespace(char *name);
    static void pythonize_method_name(char *name);

    // util
    static void *dlsym_also_try_mangled(void *handle, const char *symbol);

public:
    pymetadata();
    ~pymetadata();

    // import a c++ library under python
    static PyObject *load(char *elf_filename, char *gendata_filename=NULL, char *module_name=NULL);
    static PyObject *pyload(PyObject *self, PyObject *args);
    static PyObject *pyevent_queue_remove(PyObject *self, PyObject *args);
};

// python entry point
PyMODINIT_FUNC initpyintromit(void);

//@}
#endif

/* Offline metadata attributes:

   @metadata_attrs(
	pymetadata,
	initpyintromit:
					~select
   )
*/
